The present invention relates to a method for ascertaining a focused image distance of an optical sensor of a coordinate-measuring machine onto a workpiece to be measured, wherein the optical sensor and the workpiece are movable relative to one another in a Z direction such that a distance in the Z direction between the workpiece and the optical sensor is variable.
The present invention furthermore relates to a coordinate-measuring machine having an optical sensor and a control device for focusing the optical sensor.
Coordinate-measuring machines are generally known in the prior art. They serve for checking workpieces, for example as part of quality assurance, or for ascertaining the geometry of a workpiece completely as part of what is known as “reverse engineering.” Moreover, multifarious further application possibilities are conceivable.
In coordinate-measuring machines of this type, different types of sensors can be used to capture the coordinates of a workpiece to be measured. By way of example, sensors that measure in tactile fashion are known in this respect, as are sold for example by the applicant under the name “Vast XT” or “VAST XXT.” Here, the surface of the workpiece to be measured is probed with a stylus, with the coordinates of the stylus within the measurement space being constantly known. Such a stylus can also be moved along the surface of a workpiece, with the result that a multiplicity of measurement points can be captured at fixed time intervals during such a measurement operation as part of what is known as a “scanning method.”
It is furthermore known to use optical sensors that permit contactless capturing of the coordinates of a workpiece. One example of such an optical sensor is the optical sensor sold by the applicant under the name “ViScan”.
The sensors can then be used in different types of measurement constructions. One example of such a measurement construction is the product “O-Inspect” by the applicant. In a device of this type, both an optical sensor and a tactile sensor are used to perform various examination tasks on a machine and ideally with a single setup of a workpiece to be measured. In this way it is possible to simply perform all the examination tasks for example in medical technology, plastics technology, electronics and precision engineering. Various other constructions are, of course, also conceivable.
In one device, such as for example the “O-Inspect,” the measured workpiece is set up on a table. The table here forms an XY plane. The optical sensor is spaced apart from the workpiece to be measured perpendicularly from this plane, i.e. in the Z direction of a Cartesian coordinate system. The optical sensor should be focused onto the workpiece to be measured in dependence on the workpiece to be measured and the relative position of the optical sensor and the table with respect to one another. What applies generally here for all XY positions of the table is focusing in the Z direction.
Focusing is performed automatically by the coordinate-measuring machine. As is known, this is done by a user first manually moving the optical sensor to a position or a distance from the workpiece to be measured where he expects approximately a maximum sharpness or focus on the workpiece. He will then specify a search region in the form of a length specification or a separation in the Z direction within which the search for the maximum sharpness or best focus is to be carried out.
The camera is then moved further away from the workpiece to be measured by half of the specified search region and then moves very slowly to the end of the search region toward the workpiece. During this camera movement, images of this workpiece are captured using the optical sensor at specific time intervals and retrieved from the optical sensor by the coordinate-measuring machine. During an evaluation, what is known as a focus value of a specific region of the retrieved image is ascertained, and the position or the distance from the workpiece to be measured, in which the image request was sent, is stored together with the focus value. The multiplicity of focus values thus ascertained and the respectively associated distances from the workpiece to be measured can be used to plot what is known as a focus value curve. The coordinate-measuring machine is then able to determine an extreme value of this curve. The distance that is associated with that extreme value then represents the distance where the maximum sharpness or the best focus of the optical sensor occurs, and the optical sensor is set to this distance from the workpiece to be measured.
A multiplicity of methods are known within the prior art that can determine a focus value. For example, a region of the images can be chosen for the evaluation within which an edge of a workpiece to be measured is located. A very abrupt color transition or bright-dark transition is then located in this region. A focus value can then be, for example, the maximum gradient of the grayscale levels of the image perpendicular to the edge. The sharper an image, the greater the gradient, since ideally an abrupt transition from bright to dark occurs from one pixel to the next. The less sharp the image is, the more continuous is the bright-dark transition and the lower is the gradient. Of course, many further possibilities for determining a focus value are conceivable and known.
If owing to the system there is no possibility in such a method of directly assigning a respective image the exact distance at which it was recorded, the result may be inaccuracies in the distance determination. During a continuous camera movement through the search region, the time of use of an image requested from the optical sensor by the coordinate-measuring machine image never matches the time at which the optical sensor actually recorded the image that was supplied in response to the request. One solution in this respect was proposed for example in the document DE 10 2011 116 734 A1.
A further possibility for setting the ascertainment of an optimum focus of an optical sensor is disclosed for example in document DE 10 2009 027 353 A1. A normalized focus value curve is stored here for the specific optical sensor. As a result it is possible, even with a small number of recordings, to ascertain an instantaneous position of the optical sensor on the normalized focus value curve and to bring the optical sensor then into a position which corresponds to an optimum position on the normalized focus value curve. While it is possible in this way to provide relatively quick autofocusing, generally the accuracy requirements needed in coordinate measuring technology are not met. Moreover, this document discloses several examples of determining focus values.
Moreover, several further possibilities for increasing the accuracy of a method for determining the best possible focusing of an optical sensor have been proposed.
For example, document DE 10 2007 039 981 A1, which was mentioned in the introductory part, proposes to “fit” the ascertained focus values with a function in a specific region of the focus value curve and to then evaluate this curve.
It is furthermore known, for example from documents DE 102 15 135 A1 and DE 10 2007 003 059 A1, to ascertain a plurality of different focus criteria in an image and to sum them up or to take a weighted average so as to ascertain with the highest possible degree of accuracy the location of the distance of maximum sharpness.
Furthermore, documents 10 2005 009 554 A1 and WO 2006/125466 A1 disclose different proposals for determining focus values of recorded image stacks.
Document WO 2014/023780 A1 discloses a coordinate-measuring machine having a workpiece holder for holding a measurement object, and a measurement head that is movable relative to the workpiece holder. The measurement head carries an optical sensor. An evaluation and control unit is configured to determine spatial coordinates on the measurement object in dependence on a position of the measurement head relative to the workpiece holder and in dependence on sensor data of the optical sensor. The optical sensor includes a lens and a camera. The lens has a stop and at least 4 separate lens element groups, three of which are individually displaceable along the optical axis of the lens. The stop is furthermore also individually displaceable along the optical axis. A first lens element group is arranged fixedly in the region of the light-entry opening of the lens. A coordinate-measuring machine having such a lens permits the variation of magnification, focusing, resolution and others across a wide area of application.
Such sensors are distinguished in particular by being able to operate at many different working distances between the optical sensor and the workpiece. Moreover, they are able to operate with different, arbitrarily selected magnifications. Among other things, this also permits without problems measurement of workpieces having relatively large height differences. At the same time it has the consequence that the space region in which a plane of best focus can be located becomes relatively large in principle. It is more difficult for a user to estimate in advance whereabouts the plane of best focus will be located. As a result it becomes necessary to initially set a relatively large “catchment region” to ensure that the plane of best focus is located within this catchment region. The catchment region here refers to the region across which a search for the plane of best focus is started.
However, a relatively large catchment region has so far been associated with two disadvantages. One, it takes a relatively long time until a plane of best focus is found, since a relatively large distance needs to be traveled. Second, the reproducibility of the result for the plane of best focus decreases. This could be countered by increasing the number of recordings within the catchment region and/or reducing the speed at which the catchment region is traveled. However, this results in a further increase of the time needed for the autofocusing. Consequently, it is either possible to achieve only very slow focusing, or it is necessary to limit a maximum size of the catchment region, which is undesired and carries the risk that the plane of best focus is actually located outside the catchment region.